Skip to content

Conversation

@code-fiasco
Copy link

Summary

Add a TinyUSB USB menu option for Generic STM32F4 boards to improve compatibility with the Adafruit TinyUSB Arduino library.

This PR fixes/implements the following bugs/features

Feature

  • Adds a TinyUSB USB menu option for GenF4 boards in boards.txt
  • Enables ARDUINO_ARCH_TINYUSB via build.usb_flags when selected

Non-breaking

  • Existing USB options and behavior are unchanged unless TinyUSB is explicitly selected

Motivation

I have completed the STM32 port files for the Adafruit TinyUSB Arduino library and a pull request has been submitted upstream to include them after testing.

Without a dedicated USB menu option in the STM32 core, using TinyUSB currently requires sketch-level workarounds or manual defines. Adding a TinyUSB option in boards.txt allows the core to expose the required build flag cleanly and consistently.

This change enables TinyUSB to work across all STM32F4 boards using the Generic core configuration, simplifying usage and improving compatibility.

While this approach could be extended to other STM32 families in the future, testing for this change has currently been limited to an STM32F411 BlackPill board.

Validation

  • CI build passes
  • Tested on STM32F411 BlackPill
  • Verified TinyUSB CDC works without requiring sketch-level #define workarounds

Code formatting

  • No source formatting changes required (boards.txt only)
  • CI AStyle unaffected

Closing issues

  • N/A

Allows user to make use of TinyUSB if using Generic F4 boards.
@fpistm
Copy link
Member

fpistm commented Jan 27, 2026

Hi @code-fiasco
thanks for this PR.
Could you explain how to test, please?

I've planned to add tinyUSB support in the coming month. And also deployed the PluggableUSB from ARduinoCore-API.

@code-fiasco
Copy link
Author

Hi,

Yeah no problem!

You'll want to install the version of the TinyUSB library from this link:
https://github.com/code-fiasco/Adafruit_TinyUSB_Arduino/tree/stm32f4-support

Then using the updated boards.txt you should be able to select 'Adafruit TinyUSB' in the USB Support menu in arduino IDE. With that selected all the TinyUSB examples should work with no further modification.

I've only tested it with an F411 board as that's all I have, but it should work with all F4 boards so do let me know if you test it on anything else. Hoping the port files will be added to the main TinyUSB branch soon.

@code-fiasco
Copy link
Author

Sorry I just realised I haven't given you the actual lines for the boards.txt! All that needs adding to work with that branch of TinyUSB is:

GenF4.menu.usb.TinyUSBMIDI=Adafruit TinyUSB
GenF4.menu.usb.TinyUSBMIDI.build.usb_flags={build.extra_flags} -DARDUINO_ARCH_TINYUSB

@fpistm
Copy link
Member

fpistm commented Jan 27, 2026

No worry. It is in the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants